﻿using Microsoft.Reporting.Map.WebForms.BingMaps;
using Microsoft.SqlServer.Server;
using ReportSystem_XY.Common;
using ReportSystem_XY.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;

namespace ReportSystem_XY.DAL
{
    public class ReportNameSearchDAL : BQuery<ReportNameModel>
    {
        public List<ReportNameModel> GetReportNameList(string beginDate, string beginTime, string endDate, string endTime, int reporttype)
        {
            string strWhere = "";
            string start = beginDate + " " + beginTime;
            string end = endDate + " " + endDate;
            SqlParameter[] paras =
             {
              new SqlParameter("@start",start),
              new SqlParameter("@end",end),
                new SqlParameter("@reporttype",reporttype)
            };

            if (@reporttype == 0)
            {//(logtime between '@start' and '@end') and
                strWhere = "SELECT DISTINCT [reportname],[logtime],[username],[stepno],[processtype],[time],[temp],[ptct],[devicetype],[reporttype] FROM TBLSTEPINFO  "+
                   "where  logtime between @start and @end and reporttype = @reporttype AND processtype = 9";
            }
            //查找CIP的报表清单
            else if (reporttype == 1)
            {
                strWhere = "SELECT DISTINCT [reportname],[logtime],[username],[stepno],[processtype],[time],[temp],[ptct],[devicetype],[reporttype] FROM TBLSTEPINFO  " +
                     "where logtime between @start and @end and reporttype = @reporttype AND processtype = 9";
            }
            ////查找PRO的报表清单
            else if (reporttype == 2)
            {
                strWhere = "SELECT DISTINCT REPORTNAME,USERNAME,temp=-1.0,time=-1.0,ptct=-1.0,devicetype=-1,reporttype=2,logtime=' ',stepno=-1,processtype=-1 FROM v_productInfo  " +
                    "where starttime between @start and @end  order by reportname";
            }
            return GetModelList(strWhere,  paras);
        }
    }
}